(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('apf.popup.payment.partialPayType',partialPayTypeController);
	partialPayTypeController.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'ajaxServiceFactory', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig', 'validatorConfig', 'authService', 'buyBackService' ];
	function partialPayTypeController($scope, $q, $uibModalInstance, Constants, ajaxServiceFactory, dialogsModule, gridService, modalService, layoutConfig, validatorConfig, authService, buyBackService) {
		var ctrl = this;
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.partialPayType = {};
		ctrl.partialPayType.label ="label.partialpay.";
		
		ctrl.ok = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['ok'] || dialogsModule.btnCallback['ok']([{"partialPayType" : angular.toJson(ctrl.partialPayType)}]) !== false) {
				$uibModalInstance.close();
			}
		};
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
		ctrl.init = function() {
			ctrl.partialPayTypeOptions =
				[{"label" : "label.partialPayType.n", "value" : "NOT-ALLOWED"},
				 {"label" : "label.partialPayType.p", "value" : "PERCENTAGE"},
				 {"label" : "label.partialPayType.a", "value" : "AMOUNT"},
				 {"label" : "label.partialPayType.b", "value" : "BALANCE"}];
			buyBackService.getCurrencyOptions().then(function(response) {
				ctrl.ccyOptions = response.data;
			});
			if(dialogsModule.params.partialPayType){
				ctrl.partialPayType = angular.fromJson(dialogsModule.params.partialPayType);
			};
		};
	}
})(angular);
